package day04;

public class ColaEmployee {
    protected String name;
    protected int birthMonth;

    public ColaEmployee(String name, int birthMonth) {
        this.name = name;
        this.birthMonth = birthMonth;
    }

    public double getSalary(int month) {
        return 0;
    }
}

class SalariedEmployee extends ColaEmployee {
    private double monthlySalary;
    public SalariedEmployee(String name, int birthMonth, double monthlySalary) {
        super(name, birthMonth);
        this.monthlySalary = monthlySalary;
    }
    public double getSalary(int month) {
        double salary = monthlySalary;
        if (month == birthMonth) {
            salary += 100;
        }
        return salary;
    }

}


class HourlyEmployee extends ColaEmployee {
    private double hourlyRate;
    private int hoursWorked;

    public HourlyEmployee(String name, int birthMonth, double hourlyRate, int hoursWorked) {
        super(name, birthMonth);
        this.hourlyRate = hourlyRate;
        this.hoursWorked = hoursWorked;
    }

    @Override
    public double getSalary(int month) {
        double salary = hourlyRate * hoursWorked;
        if (hoursWorked > 160) {
            salary += 1.5 * (hoursWorked - 160) * hourlyRate; // 超出160小时的部分
        }
        if (month == birthMonth) {
            salary += 100;
        }
        return salary;
    }

}


class SalesEmployee extends ColaEmployee {
    private double monthlySales;
    private double commissionRate;

    public SalesEmployee(String name, int birthMonth, double monthlySales, double commissionRate) {
        super(name, birthMonth);
        this.monthlySales = monthlySales;
        this.commissionRate = commissionRate;
    }

    @Override
    public double getSalary(int month) {
        double salary = monthlySales * commissionRate;
        if (month == birthMonth) {
            salary += 100;
        }
        return salary;
    }
}
class Company {
    public void printEmployeeSalary(ColaEmployee[] employees, int month) {
        for (ColaEmployee employee : employees) {
            double salary = employee.getSalary(month);
            System.out.println(employee.name + " 在 " + month + " 月的工资为: " + salary);
        }
    }
}


